import axios from 'axios';

let api={
    getArticleList:'/api-web/v1/api/article/list/all',
    getArticleDetail:'/api-web/v1/api/article/uuid/',
    reviseArticle:'/api-web/v1/api/article',
    changeOnTop:'/api-web/v1/api/article',
    deleteArticle:'/api-web/v1/api/article',
    createArticle:'/api-web/v1/api/article',
}

const getArticleList = (params) => {
    // console.log(params);
    return axios.get(api.getArticleList+'?orderBy='+params.orderBy+'&xsc='+params.xsc+'&keyword='+params.keyword+'&type='+params.type+'&dateStart='+params.dateStart+'&dateEnd='+params.dateEnd+'&curPage='+params.curPage+'&pageSize='+params.pageSize);
}

const createArticle = (params) => {
    return axios.post(api.createArticle,params);
}

const checkArticleDetail = (params) => {
    return axios.get(api.getArticleDetail+'/'+params);
}

const reviseArticle = (id,params) => {
    return axios.post(api.reviseArticle+'/'+id,params);
}

const changeOnTop = (uuid) => {
    return axios.post(api.changeOnTop+'/'+uuid+'/changeOnTop',uuid);
}

const deleteArticle = (uuid) => {
    return axios.post(api.deleteArticle+'/'+uuid+'/delete',uuid);
}

export{
    api,
    createArticle,
    getArticleList,
    checkArticleDetail,
    reviseArticle,
    changeOnTop,
    deleteArticle
}